<!DOCTYPE HTML>
<title>textarea element setting value property should reset text selection</title>
<link rel="author" title="yaycmyk" href="mailto:evan@yaycmyk.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#textFieldSelection">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
  "use strict";

  test(() => {
    const element = document.createElement("textarea");

    element.value = "foo";

    assert_equals(element.selectionStart, 0);
    assert_equals(element.selectionEnd, 0);
    assert_equals(element.selectionDirection, "none");

    element.select();

    assert_equals(element.selectionStart, 0);
    assert_equals(element.selectionEnd, 3);
    assert_equals(element.selectionDirection, "none");

    element.value = "bar";

    assert_equals(element.selectionStart, 0);
    assert_equals(element.selectionEnd, 0);
    assert_equals(element.selectionDirection, "none");

  }, "textarea setting value should reset selection indexes back to defaults");
</script>
